<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head>
  <meta charset="utf-8">
  <title>流程部署</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
  <link rel="stylesheet" th:href="@{/adminui/dist/css/admin.css}" media="all">
  <link rel="stylesheet" th:href="@{/style/custom.css}" media="all">
</head>
<body>

<div class="layui-upload-drag" style="display: block;" id="definition-upload">
  <i class="layui-icon layui-icon-upload"></i>
  <div>点击上传，或将文件拖拽到此处</div>
</div>
<div class="layui-form-item layui-hide">
  <input type="button" lay-submit lay-filter="LAY-upload-front-submit" id="LAY-upload-front-submit" value="确认">
</div>


<script th:src="@{/layui/layui.js}"></script>
<script>
  layui.config({
    base: '/'
  }).extend({
    flying: 'flying'
  }).use(['index', 'flying'], function(){
    const $ = layui.$
        ,admin = layui.admin
        ,form = layui.form
        ,table = layui.table
        ,layer = layui.layer
        ,upload = layui.upload
        ,flying = layui.flying;

    let layering;
    // 渲染
    upload.render({
      elem: '#definition-upload',
      url: '/flow/definition/deploy', // 实际使用时改成您自己的上传接口即可。
      auto: false,
      accept: 'file', // 普通文件
      bindAction: '#LAY-upload-front-submit',
      before: function(obj){ // obj 参数同 choose
        layering = layer.load(); // 上传 loading
      },
      done: function(res){
        layer.close(layering);
        //执行成功
        let index = parent.layer.getFrameIndex(window.name);//获取当前弹出层的层级
        layer.msg(res.msg, {icon: 1, time: 900}, function () {
          parent.layer.close(index);//关闭弹出层
        });
      }
    });
  });
</script>
</body>
</html>